package utils

import (
	"fmt"

	"github.com/linclaus/stock/pkg/db"
	"github.com/linclaus/stock/pkg/weixin/model"
)

func GetUserInfo(openId string) model.UserInfo {
	user, _ := db.UserMgr.GetUserByOpenId(openId)
	total, err := db.UserStrategyMgr.CountStrategyByUserId(user.Id)
	if err != nil {
		fmt.Printf("Count err: %s\n", err.Error())
	}
	userInfo := model.UserInfo{
		CurrentStrategiesNum: total,
		MaxStrategiesNum:     user.MaxStrategyNum,
		Email:                user.Email,
	}
	return userInfo
}
